1 import sqlite3
2
3 def connect():
4        con = sqlite3.connect(
'fee.db')
5        cur = con.cursor()
6
7        cur.execute(
'CREATE TABLE IF NOT EXISTS fee(id INTEGER PRIMARY KEY, recpt integer, name text, admsn text, date integer, \
8                     branch text, sem text, total integer, paid integer, due integer)
')
9
10        con.commit()
11        con.close()
12
13 def insert(recpt =
' ', name = ' ', admsn = ' ', date = ' ', branch = ' ', sem = ' ', total = ' ', paid = ' ', due = ' '):
14        con = sqlite3.connect(
'fee.db')
15        cur = con.cursor()
16
17        cur.execute(
'INSERT INTO fee VALUES (NULL,?,?,?,?,?,?,?,?,?)',(recpt,name,admsn,date,branch,sem,total,paid,due))
18
19        con.commit()
20        con.close()
21
22 def view():
23        con = sqlite3.connect(
'fee.db')
24        cur = con.cursor()
25
26        cur.execute(
'SELECT * FROM fee')
27        row = cur.fetchall()
28        
return row
29
30        con.commit()
31        
32
33 def delete(id):
34        con = sqlite3.connect(
'fee.db')
35        cur = con.cursor()
36
37        cur.execute(
'DELETE FROM fee WHERE id = ?',(id,))
38
39        con.commit()
40        con.close()
41
42 def update(id,recpt =
' ', name = ' ', admsn = ' ', date = ' ', branch = ' ', sem = ' ', total = ' ', paid = ' ', due = ' '):
43        con = sqlite3.connect(
'fee.db')
44        cur = con.cursor()
45
46        cur.execute(
'UPDATE fee SET recpt = ? OR name = ? OR admsn = ? OR date = ? OR branch = ? OR sem = ? OR total = ? OR \
47                     paid = ? OR due = ?
',(recpt,name,admsn,date,branch,sem,total,paid,due))
48
49
50        con.commit()
51        con.close()
52
53 def search(recpt =
' ', name = ' ', admsn = ' ', date = ' ', branch = ' ', sem = ' ', total = ' ', paid = ' ', due = ' '):
54        con = sqlite3.connect(
'fee.db')
55        cur = con.cursor()
56
57        cur.execute(
'SELECT * FROM fee WHERE recpt = ? OR name = ? OR admsn = ? OR date = ? OR branch = ? OR sem = ? OR \
58                     total = ? OR paid = ? OR due = ?
',(recpt,name,admsn,date,branch,sem,total,paid,due))
59        row = cur.fetchall()
60        
return row
61
62        con.commit()
63        
64 connect()


Gõ tìm kiếm nhanh...